package com.example.dts.model;

import com.example.dts.type.StudioStatus;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Entity
@Table(name = "studio")
@Data
@ToString(callSuper = true)
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
public class Studio extends BaseEntity implements Serializable {

    private static final long serialVersionUID = -40356785423868312L;

    @Id
    @GenericGenerator(name = "uuidG", strategy = "org.hibernate.id.UUIDGenerator")
    @GeneratedValue(generator = "uuidG")
    @Column(name = "id", length = 50)
    private String id;

    @Column(name = "studio_cover_url")
    private String studioCoverUrl;

    @Column(name = "title")
    private String title;

    @Column(name = "watch_number")
    private long watchNumber = 0;

    @Column(name = "appointment_number")
    private long appointmentNumber = 0;

    @Column(name = "studio_status")
    @Enumerated(EnumType.STRING)
    private StudioStatus studioStatus=StudioStatus.NOT_STARTED;

    @Column(name = "push_url")
    private String pushUrl;

    @Column(name = "pull_url")
    private String pullUrl;

    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date startTime;

    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date endTime;

    @Column(name = "brief_introduction")
    private String briefIntroduction;
}
